home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Found / FWExcLib / Include / FWPostEx.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-21  |  2.4 KB  |  88 lines  |  [TEXT/MPS ]

  1. #ifndef FWPOSTEX_H
  2. #define FWPOSTEX_H
  3. //========================================================================================
  4. //
  5. //    File:                FWPostEx.h
  6. //    Release Version:    $ 1.0d1 $
  7. //
  8. //    Creation Date:        3/28/94
  9. //
  10. //    Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  11. //
  12. //========================================================================================
  13.  
  14. #ifndef   FWEXCEPT_H
  15. #include "FWExcept.h"
  16. #endif
  17.  
  18. #ifndef   FWSPOSTE_H
  19. #include "FWSPostE.h"
  20. #endif
  21.  
  22. #ifndef   FWPRITAS_H
  23. #include "FWPriTas.h"
  24. #endif
  25.  
  26. //========================================================================================
  27. // CLASS FW_CPostedException
  28. //========================================================================================
  29.  
  30. class FW_CPostedException
  31. {
  32.  
  33. public:
  34.  
  35.     static void Initialize(FW_SPrivPostedExceptionGlobals& globals);
  36.         // Initialize.  Should only be called once, before any exception is posted.
  37.         // Exception buffer is allocated as maxExceptionSize bytes.
  38.         
  39.     static void Terminate();
  40.         // Cleanup.  Releases exception buffer.
  41.  
  42.     static void PostException(const _FW_CException& exception);
  43.         // Post an exception.
  44.         // No-op if posted exception already pending.
  45.     
  46.     static short IsPendingException();
  47.         // Returns 1 if an exception has been posted and not yet thrown.
  48.         // Returns 0 otherwise.
  49.     
  50.     static void ThrowPostedException();
  51.         // Throw the posted exception.
  52.         // It is a no-op to invoke this function if no exception is pending.
  53.  
  54.     static FW_SPrivPostedExceptionGlobals&    GetPostedExceptionGlobals();
  55.  
  56. private:
  57.  
  58.     enum
  59.     {
  60.         kPostedExceptionGlobals = 116
  61.     };
  62.     
  63. };
  64.  
  65. //========================================================================================
  66. // FW_CPostedException inline functions
  67. //========================================================================================
  68.  
  69. //----------------------------------------------------------------------------------------
  70. //    FW_CPostedException::GetPostedExceptionGlobals
  71. //----------------------------------------------------------------------------------------
  72.  
  73. inline FW_SPrivPostedExceptionGlobals& FW_CPostedException::GetPostedExceptionGlobals()
  74. {
  75.     FW_SPrivPostedExceptionGlobals *globals = (FW_SPrivPostedExceptionGlobals*)
  76.                 FW_CPrivTaskGlobals::GetTaskGlobals(kPostedExceptionGlobals);
  77.     if (globals->gInitialized == 0)
  78.         Initialize(*globals);
  79.     return *globals;
  80. }
  81.  
  82. inline short FW_CPostedException::IsPendingException()
  83. {
  84.     return GetPostedExceptionGlobals().gPending;
  85. }
  86.  
  87. #endif
  88.